package cn.lingyangwl.agile.infra.module.dict.model.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.lingyangwl.agile.model.BasePlusPO;
import cn.lingyangwl.agile.model.module.dict.CusFieldBind;
import cn.lingyangwl.agile.model.module.dict.DictTypeCons;
import cn.lingyangwl.framework.mybatis.mate.annotations.FieldUnique;
import cn.lingyangwl.framework.mybatis.mate.annotations.FieldUniqueConfig;
import cn.lingyangwl.framework.mybatis.mate.enums.SqlConditionTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

/**
 * 字典类型表 sys_dict_type
 * 
 * @author shenguangyang
 */
@Getter
@Setter
@ToString
@FieldUniqueConfig(sqlCondition = SqlConditionTypeEnum.AND)
@TableName("dict")
public class Dict extends BasePlusPO {
    private static final long serialVersionUID = 1L;

    public static LambdaQueryWrapper<Dict> lqw() {
        return Wrappers.lambdaQuery();
    }

    public static LambdaUpdateWrapper<Dict> luw() {
        return Wrappers.lambdaUpdate();
    }

    /** 字典主键 */
    @TableId
    private Long id;

    /** 字典名称 */
    @NotBlank(message = "字典名称不能为空")
    @Size(min = 1, max = 100, message = "字典名称长度不能超过100个字符")
    private String dictName;

    /** 字典编码 */
    @NotBlank(message = "字典编码不能为空")
    @Size(min = 1, max = 100, message = "字典编码长度不能超过100个字符")
    @FieldUnique(message = "字典编码已存在")
    private String dictCode;

    /** 字典编码 */
    @FieldUnique(message = "字典编码已存在")
    private Long groupId;

    /** 状态（1正常 2停用） */
    @CusFieldBind(type = DictTypeCons.DICT_ITEM_STATUS, target = "statusText")
    @Excel(name = "状态", dict = DictTypeCons.DICT_ITEM_STATUS)
    private String status;

    /** 绑定显示属性，非表字典（排除） */
    @TableField(exist = false)
    private String statusText;
}
